import { Opt } from '__com/Opt.js'
import ruleOpt from '@/option/rule.js'
import rolesOpt from '@/option/roles.js'

export class editOpt extends Opt {
  constructor(fun) {
    super(fun)
  }

  create() {
    return [
      [
        {
          title: '人员姓名',
          key: 'userName',
          input: {
            maxlength: 10
          },
          placeholder: '请输入人员姓名',
          rules: [ruleOpt.required('人员姓名不能为空')]
        },
        {
          title: '人员编号',
          key: 'workNo',
          text: {}
        }
      ],
      [
        {
          title: '人员状态',
          key: 'state',
          text: {},
          data: {
            from: (info) => {
              return info.state == 1 ? '启用' : '禁用'
            }
          }
        },

        rolesOpt.createSysRole({
          col: 12,
          key: 'roleIds',
          title: '人员角色',
          multiple: true,
          maxTagCount: 2,
          rules: [ruleOpt.required('人员角色不能为空', 'array')]
        })
      ],
      [
        {
          title: '手机号',
          key: 'phone',
          input: {
            maxlength: 11
          },
          placeholder: '请输入手机号',
          rules: [ruleOpt.required('手机号不能为空'), ruleOpt.phone()]
        },
        {
          title: '重置密码',
          key: 'password',
          button: {
            title: '立即重置',
            style: {
              color: '#2D61F4'
            },
            type: 'text',
            code: '0605000000',
            click: (d) => {
              this.resetPassWord(d)
            }
          }
        }
      ]
    ]
  }
}
